package pack1;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;


import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;


public class sprg31 {
	
	public static void main(String[] args) throws InvalidFormatException, IOException {
FileInputStream fin = new FileInputStream("d:/book1.xlsx");		
Workbook wb = WorkbookFactory.create(fin);
Sheet s = wb.getSheet("sheet1");
//Row r = s.createRow(1);
//Cell c = r.createCell(1);
int rc=s.getLastRowNum();



//String str = c.getStringCellValue();
System.out.println(rc);
	for(int i=0;i<=rc;i++)
	{
		int c=s.getRow(i).getLastCellNum();
		
		for(int j=0;j<c;j++)
		System.out.print(s.getRow(i).getCell(j).getStringCellValue()+" ");
	System.out.println();
	}
	//c.setCellValue("hello");


FileOutputStream fos=new FileOutputStream("d:/book1.xlsx");
wb.write(fos);

//for()
	}

}
